Fix bug where watch messages doesn't go out. Also change xs_test
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 26 Jul 2005 15:23:50 +0000 (15:23 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 26 Jul 2005 15:23:50 +0000 (15:23 +0000)
to more closely represent xenbus behaviour so we can see the bug.
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/xenstore/xenstored_core.c
tools/xenstore/xs_test.c

index 386d323d37e325da8f05f2c6218df232ab84f4aa..3689ea4b569024a6fc814365bb3f8a2f91d31e49 100644 (file)
@@ -253,7 +253,7 @@ static bool write_message(struct connection *conn)
                out->used = 0;
 
                /* Second write might block if non-zero. */
-               if (out->hdr.msg.len)
+               if (out->hdr.msg.len && !conn->domain)
                        return true;
        }
 
index b7b1ee01ed5946c6287cf3e717451694a8796472..13bbbf2d68dacc59a6edc97aa82d4b70a19ed8da 100644 (file)
@@ -85,6 +85,14 @@ static const void *get_input_chunk(const struct ringbuf_head *h,
        return buf + h->read;
 }
 
+static int output_avail(struct ringbuf_head *out)
+{
+       unsigned int avail;
+
+       get_output_chunk(out, out->buf, &avail);
+       return avail != 0;
+}
+
 static void update_output_chunk(struct ringbuf_head *h, uint32_t len)
 {
        h->write += len;
@@ -104,10 +112,12 @@ static bool read_all_shmem(int fd __attribute__((unused)),
                           void *data, unsigned int len)
 {
        unsigned int avail;
+       int was_full;
 
        if (!check_buffer(in))
                barf("Corrupt buffer");
 
+       was_full = !output_avail(in);
        while (len) {
                const void *src = get_input_chunk(in, in->buf, &avail);
                if (avail > len)
@@ -119,7 +129,8 @@ static bool read_all_shmem(int fd __attribute__((unused)),
        }
 
        /* Tell other end we read something. */
-       kill(daemon_pid, SIGUSR2);
+       if (was_full)
+               kill(daemon_pid, SIGUSR2);
        return true;
 }